<template>
  <div>
    <div style="margin: 20px 20px;">
      <el-row>
        <el-col :span="6" v-for="(btn,index) in buttonList" :offset="2" :key="index">
          <el-button :plain="btn.active" :type="btn.type" @click="handleButtonClick(index)">{{btn.title}}
          </el-button>
        </el-col>
      </el-row>
    </div>
    <div style="margin:0px 5px;border-bottom: 1px solid #cccccc;"></div>
    <div>
      <keep-alive>
        <component :is="currentView" :date="date"></component>
      </keep-alive>
    </div>
    <div style="text-align: center;padding-top:20px;">
      <el-button :plain="true" type="info" style="border: 1px solid #1f76dc;color: #1f76dc;">
        打印请点击此处
      </el-button>
    </div>
  </div>
</template>
<script>
  import {mapGetters,mapActions} from 'vuex'
  import vPrintWljd from '../../components/PrintWljd.vue'
  import vPrintZzcj from '../../components/PrintZzcj.vue'
  import vPrintZzjd from '../../components/PrintZzjd.vue'

  export default {
    components: {
      vPrintWljd, vPrintZzcj, vPrintZzjd
    },
    computed:{
      ...mapGetters(['reportDetail']),
      date() {
        return this.reportDetail.createdAt ?this.reportDetail.createdAt.substring(0, 10):'';
      }
    },
    data() {
      return {
        currentView: 'vPrintWljd',
        buttonList: [
          {
            title: '外联接待入境旅游',
            index: 'vPrintWljd',
            type: 'primary',
            active: false,
          },
          {
            title: '组织接待国内旅游',
            index: 'vPrintZzjd',
            type: 'success',
            active: true,
          },
          {
            title: '组织出境旅游',
            index: 'vPrintZzcj',
            type: 'warning',
            active: true,
          }
        ]
      }
    },
    methods: {
      handleButtonClick(index) {
       if (this.buttonList[index].active) {
          this.buttonList.map(btn => {
            btn.active = true;
          });
          this.buttonList[index].active = false;
          this.currentView = this.buttonList[index].index;
        }
      },
    }
  }
</script>
<style>

</style>
